import { isNumber } from "lodash";
import { ColSpanInfo, LandUseTypeAnalysisParams, ReportParagraphBlock, RowSpanInfo } from "./typings/index";
import {
    isEmpty, getCellValueTotalByColGroup, getPercent, presetWorkSheet,
    getTableMatrixRowTotalValueMax, generateWordParagraBlockByPlainText,
    removeAndAdjustColumn,
    generateWordParagraBlockByTableGenerateResult,
    processWordParagraphBlockList
} from "./utils";





// const landUseTypeAnalysis = (params: LandUseTypeAnalysisParams): ReportParagraphBlock[] => {
//     const {
//         workSheet
//     } = params;
//     const newWorkSheet = presetWorkSheet(workSheet);
//     const protectlandName = '保护地';
//     let workSheet2 = [...newWorkSheet].slice(3, newWorkSheet.length);
//     let tempParagraph2_1: string = `${protectlandName}总面积${getCellValueTotalByColGroup(workSheet2, 1, 0, workSheet2.length - 1)}公顷，`
//     const linyeArea = getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1);
//     if (linyeArea) {
//         tempParagraph2_1 += `其中林业用地${linyeArea}公顷，`;
//         tempParagraph2_1 += `占总面积的${getPercent(getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1), getCellValueTotalByColGroup(workSheet2, 1, 0, workSheet2.length - 1))}%；`;
//     }
//     const feiLinYeArea = getCellValueTotalByColGroup(workSheet2, 19, 0, workSheet2.length - 1);
//     if (feiLinYeArea) {
//         tempParagraph2_1 += `非林业用地${feiLinYeArea}公顷，占${getPercent(getCellValueTotalByColGroup(workSheet2, 19, 0, workSheet2.length - 1), getCellValueTotalByColGroup(workSheet2, 1, 0, workSheet2.length - 1))}%。`;
//     }
//     const linDiArea = getCellValueTotalByColGroup(workSheet2, 3, 0, workSheet2.length - 1) + getCellValueTotalByColGroup(workSheet2, 4, 0, workSheet2.length - 1) + getCellValueTotalByColGroup(workSheet2, 5, 0, workSheet2.length - 1);
//     if (linDiArea) {
//         tempParagraph2_1 += `在林业用地中，有林地面积${linDiArea}公顷，`;
//         tempParagraph2_1 += `占林业用地面积的${getPercent(getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 3, 5), getCellValueTotalByColGroup(workSheet2, 1, 0, workSheet2.length - 1))}%，`;
//     }
//     const arborArea = getCellValueTotalByColGroup(workSheet2, 3, 0, workSheet2.length - 1);
//     if (arborArea) {
//         const hongLinDiArea = getCellValueTotalByColGroup(workSheet2, 4, 0, workSheet2.length - 1);
//         const zhuLinDiArea = getCellValueTotalByColGroup(workSheet2, 5, 0, workSheet2.length - 1);
//         const shuLinDiArea = getCellValueTotalByColGroup(workSheet2, 6, 0, workSheet2.length - 1);
//         tempParagraph2_1 += `乔木林地${getCellValueTotalByColGroup(workSheet2, 3, 0, workSheet2.length - 1)}公顷，`;
//         if (hongLinDiArea) {
//             tempParagraph2_1 += `红树林地${hongLinDiArea}公顷，`;
//         }
//         if (zhuLinDiArea) {
//             tempParagraph2_1 += `竹林地${zhuLinDiArea}公顷；`;
//         }
//         if (shuLinDiArea) {
//             tempParagraph2_1 += `疏林地面积${shuLinDiArea}公顷，`;
//         }
//         tempParagraph2_1 += `占林业用地面积的${getPercent(getCellValueTotalByColGroup(workSheet2, 6, 0, workSheet2.length - 1), getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1))}%；`;
//     }
//     const shrubArea = getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 7, 8);
//     if (shrubArea) {
//         tempParagraph2_1 += `灌木林地${shrubArea}公顷，占林业用地面积的${getPercent(getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 7, 8), getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1))}%；`;
//     }
//     const weiChenLinDiArea = getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 9, 10);
//     if (weiChenLinDiArea) {
//         tempParagraph2_1 += `未成林地${weiChenLinDiArea}公顷，占林业用地面积的${getPercent(getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 9, 10), getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1))}%；`;
//     }
//     const miaoPuDiArea = getCellValueTotalByColGroup(workSheet2, 11, 0, workSheet2.length - 1);
//     if (miaoPuDiArea) {
//         tempParagraph2_1 += `苗圃地${miaoPuDiArea}公顷，占林业用地面积的${getPercent(getCellValueTotalByColGroup(workSheet2, 11, 0, workSheet2.length - 1), getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1))}%；`;
//     }
//     const wuLiMuLinDiArea = getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 12, 14);
//     if (wuLiMuLinDiArea) {
//         tempParagraph2_1 += `无立木林地${wuLiMuLinDiArea}公顷，占林业用地面积的${getPercent(getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 12, 14), getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1))}%；`;
//     }
//     const YiLinDiArea = getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 15, 17);
//     if (YiLinDiArea) {
//         tempParagraph2_1 += `宜林地${YiLinDiArea}公顷，占林业用地面积的${getPercent(getTableMatrixRowTotalValueMax(workSheet2, 0, workSheet2.length - 1, 15, 17), getCellValueTotalByColGroup(workSheet2, 2, 0, workSheet2.length - 1))}%。`;
//     }
//     const genDiMianJi = getCellValueTotalByColGroup(workSheet2, 20, 0, workSheet2.length - 1);
//     const muCaoDiMianJi = getCellValueTotalByColGroup(workSheet2, 21, 0, workSheet2.length - 1);
//     const shuiYuMianJi = getCellValueTotalByColGroup(workSheet2, 22, 0, workSheet2.length - 1);
//     const weiLiYongDiMianJi = getCellValueTotalByColGroup(workSheet2, 23, 0, workSheet2.length - 1);
//     const jianSheYongDiMianJi = getCellValueTotalByColGroup(workSheet2, 24, 0, workSheet2.length - 1);
//     if (genDiMianJi) {
//         tempParagraph2_1 += `在非林业用地中，耕地面积${genDiMianJi}公顷，`;
//     }
//     if (genDiMianJi) {
//         tempParagraph2_1 += `牧草地面积${muCaoDiMianJi}公顷，`;
//     }
//     if (genDiMianJi) {
//         tempParagraph2_1 += `水域面积${shuiYuMianJi}公顷，`;
//     }
//     if (genDiMianJi) {
//         tempParagraph2_1 += `未利用地面积${weiLiYongDiMianJi}公顷，`;
//     }
//     if (genDiMianJi) {
//         tempParagraph2_1 += `建设用地面积${jianSheYongDiMianJi}公顷。`;
//     }
//     let tempWordParahraphList2: ReportParagraphBlock[] = [];
//     tempWordParahraphList2.push(generateWordParagraBlockByPlainText('地类统计分析', 'heading1'));
//     tempWordParahraphList2.push(generateWordParagraBlockByPlainText(tempParagraph2_1, 'normalParagraph'))
//     tempWordParahraphList2.push(generateWordParagraBlockByPlainText(`表  ${protectlandName}土地利用现状表`, 'smallTableName'))
//     //纵向合并（只要colIndex命中，就删除掉）
//     let tableRowSpanListForTuDi = [
//         { rowIndex: 0, colIndex: 0, rowSpan: 3 },
//         { rowIndex: 0, colIndex: 1, rowSpan: 3 },
//         { rowIndex: 1, colIndex: 2, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 6, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 11, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 18, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 19, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 20, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 21, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 22, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 23, rowSpan: 2 },
//         { rowIndex: 1, colIndex: 24, rowSpan: 2 },
//     ]
//     let tableColSpanListForTuDi = [
//         { rowIndex: 0, colIndex: 2, colSpan: 17, originColSpan: 17, deleteCount: 0 },
//         { rowIndex: 1, colIndex: 3, colSpan: 3, originColSpan: 3, deleteCount: 0 },
//         { rowIndex: 1, colIndex: 7, colSpan: 2, originColSpan: 2, deleteCount: 0 },
//         { rowIndex: 1, colIndex: 10, colSpan: 2, originColSpan: 2, deleteCount: 0 },
//         { rowIndex: 1, colIndex: 12, colSpan: 2, originColSpan: 2, deleteCount: 0 },
//         { rowIndex: 1, colIndex: 15, colSpan: 2, originColSpan: 2, deleteCount: 0 },
//         { rowIndex: 0, colIndex: 19, colSpan: 6, originColSpan: 6, deleteCount: 0 },
//     ]
//     let columnTotalAreaIsEmptyOrNullIndexList: number[] = [];
//     let tableDataForTuDi = [...workSheet];
//     for (let i = 0; i < 24; i++) {
//         if (i > 1) {
//             let tempColumnTotalValue = getCellValueTotalByColGroup(workSheet2, i, 0, workSheet2.length - 1);
//             if (tempColumnTotalValue == 0 || isEmpty(tempColumnTotalValue)) {
//                 columnTotalAreaIsEmptyOrNullIndexList.push(i);
//             }
//         }
//     }
//     columnTotalAreaIsEmptyOrNullIndexList.forEach((columnIndex, _index) => {
//         tableDataForTuDi = removeAndAdjustColumn(tableDataForTuDi, columnIndex - _index, tableRowSpanListForTuDi, tableColSpanListForTuDi,)
//     })
//     tempWordParahraphList2.push(generateWordParagraBlockByTableGenerateResult({
//         tableStyle: 'normalTable',
//         tableHeaderRowNumber: 3,
//         tableData: tableDataForTuDi,
//         tableRowSpanInfoList: tableRowSpanListForTuDi,
//         tableColSpanInfoList: tableColSpanListForTuDi
//     }));
//     const resultParagraphBlockList = processWordParagraphBlockList(tempWordParahraphList2);
//     return resultParagraphBlockList;
// }


/**
 * 根据制定规则删除表格列，以及自动调整修改后的单元格合并关系
 * @param tableData 
 * @param tableColSpanInfoList 
 * @param tableRowSpanInfoList 
 * @param checkColumnNeedDeleteFun 
 * @returns 
 */
const deleteTableDataEmptyColumn = (
    tableData: string[][],
    tableColSpanInfoList: ColSpanInfo[],
    tableRowSpanInfoList: RowSpanInfo[],
    startRowIndex: number,
    checkColumnNeedDeleteFun?: (tableData: string[][], colIndex: number, startRowIndex: number) => boolean
): {
    tableData: string[][],
    tableColSpanInfoList: ColSpanInfo[],
    tableRowSpanInfoList: RowSpanInfo[]
} => {
    if (isEmpty(startRowIndex)) {
        startRowIndex = 0;
    }
    const checkTableColumnIsAllEmpty = (tableData: string[][], colIndex: number, startRowIndex: number): boolean => {
        let tableColumnIsAllEmpty: boolean = true;
        tableData.forEach(rowList => {
            if (!isEmpty(rowList[colIndex]) && Number(rowList[colIndex]) > 0) {
                tableColumnIsAllEmpty = false;
            }
        })
        return tableColumnIsAllEmpty;
    }
    let handledTableData: string[][] = [...tableData];
    let handledTableColSpanInfoList: ColSpanInfo[] = [...tableColSpanInfoList];
    let handledTableRowSpanInfoList: RowSpanInfo[] = [...tableRowSpanInfoList];
    let columnIsEmptyOrNullIndexList: number[] = [];
    for (let i = 0; i < tableData[0].length; i++) {
        const tableColumnIsNeedToDelete = checkColumnNeedDeleteFun ? checkColumnNeedDeleteFun(tableData, i, startRowIndex) : checkTableColumnIsAllEmpty(tableData, i, startRowIndex);
        if (tableColumnIsNeedToDelete) {
            columnIsEmptyOrNullIndexList.push(i);
        }
    }
    columnIsEmptyOrNullIndexList.forEach((columnIndex, _index) => {
        handledTableData = removeAndAdjustColumn(handledTableData, columnIndex - _index, handledTableRowSpanInfoList, handledTableColSpanInfoList)
    })
    return {
        tableData: handledTableData,
        tableColSpanInfoList: handledTableColSpanInfoList,
        tableRowSpanInfoList: handledTableRowSpanInfoList
    }
}

const findCellValuColIndex = (rowList: string[], cellValue: string): number => {
    let colIndex = -1;
    for (let i = 0; i < rowList.length; i++) {
        if (rowList[i] == cellValue) {
            colIndex = i;
            break;
        }
    }
    return colIndex;
}

const replaceLastCharWithPeriod = (text: string) => {
    if (text.length === 0) {
        return text; // 如果文本为空，直接返回
    }
    return text.substring(0, text.length - 1) + '。'; // 替换最后一个字符为句号
}


const getPercentRate = (value: any, totalValue: any): number => {
    let rate = ((Number(value) / Number(totalValue)) * 100).toFixed(2);
    return Number(rate);
}

const landUseTypeAnalysis = (params: LandUseTypeAnalysisParams): ReportParagraphBlock[] => {
    const protectlandName = "保护地";
    const {
        workSheet
    } = params;
    const newWorkSheet = presetWorkSheet(workSheet);
    let workSheet2 = [...newWorkSheet].slice(2, newWorkSheet.length);
    let tempWordParahraphList2: ReportParagraphBlock[] = [];
    const totalLandUseArea = getCellValueTotalByColGroup(workSheet2, 1, 0, workSheet2.length - 1);
    let tempParagraph2_1: string = `${protectlandName}总面积${totalLandUseArea}公顷，`
    let tableRowSpanListForTuDi = [
        { rowIndex: 0, colIndex: 0, rowSpan: 2 },
        { rowIndex: 0, colIndex: 1, rowSpan: 2 },
        { rowIndex: 0, colIndex: 32, rowSpan: 2 },
        { rowIndex: 0, colIndex: 33, rowSpan: 2 },
        { rowIndex: 0, colIndex: 34, rowSpan: 2 },
        { rowIndex: 0, colIndex: 35, rowSpan: 2 },
        { rowIndex: 0, colIndex: 36, rowSpan: 2 },
        { rowIndex: 0, colIndex: 37, rowSpan: 2 },
        { rowIndex: 0, colIndex: 38, rowSpan: 2 },
        { rowIndex: 0, colIndex: 39, rowSpan: 2 },
        { rowIndex: 0, colIndex: 40, rowSpan: 2 },
        { rowIndex: 0, colIndex: 41, rowSpan: 2 },
        { rowIndex: 0, colIndex: 42, rowSpan: 2 },
        { rowIndex: 0, colIndex: 43, rowSpan: 2 },
        { rowIndex: 0, colIndex: 44, rowSpan: 2 },
        { rowIndex: 0, colIndex: 45, rowSpan: 2 },
        { rowIndex: 0, colIndex: 46, rowSpan: 2 },
        { rowIndex: 0, colIndex: 47, rowSpan: 2 },
        { rowIndex: 0, colIndex: 48, rowSpan: 2 },
        { rowIndex: 0, colIndex: 49, rowSpan: 2 },
        { rowIndex: 0, colIndex: 50, rowSpan: 2 },
    ]
    let tableColSpanListForTuDi = [
        { rowIndex: 0, colIndex: 2, colSpan: 5, originColSpan: 5, deleteCount: 0 },
        { rowIndex: 0, colIndex: 7, colSpan: 4, originColSpan: 4, deleteCount: 0 },
        { rowIndex: 0, colIndex: 11, colSpan: 8, originColSpan: 8, deleteCount: 0 },
        { rowIndex: 0, colIndex: 19, colSpan: 6, originColSpan: 6, deleteCount: 0 },
        { rowIndex: 0, colIndex: 25, colSpan: 7, originColSpan: 7, deleteCount: 0 },
    ]
    let tableDataForTuDi = [...workSheet];
    const checkTableColumnTotalValueIsEmpty = (tableData: string[][], colIndex: number, startRowIndex: number): boolean => {
        let columnTotalValue = 0;
        let columnIsEmpty = true;
        const tempColCellList = [];
        tableData.forEach((rowList, rowIndex) => {
            if (rowIndex >= startRowIndex
            ) {

                const targetCellValue = rowList[colIndex].toString().trim();
                if (!isEmpty(targetCellValue) && isNumber(Number(targetCellValue)) && Number(targetCellValue) > 0) {
                    columnIsEmpty = false;
                }
                tempColCellList.push(targetCellValue);
                columnTotalValue += Number(targetCellValue)
            }
        })
        let isNeedToDelete = false;
        if (!columnIsEmpty) {
            isNeedToDelete = false;
        } else {
            if (isNumber(columnTotalValue) && Number(columnTotalValue) !== 0) {
                isNeedToDelete = false;
            } else {
                isNeedToDelete = true;
            }
        }
        console.log("colIndex--->", colIndex, columnIsEmpty, isNeedToDelete, columnTotalValue)
        return isNeedToDelete;
    }
    const tableDataForTuDiHandledResult = deleteTableDataEmptyColumn(
        tableDataForTuDi,
        tableColSpanListForTuDi,
        tableRowSpanListForTuDi,
        2,
        checkTableColumnTotalValueIsEmpty
    );
    let handledTableDataOfLandUseType = tableDataForTuDiHandledResult.tableData;
    let handledTableRowSpanInfoListOfLandUseType = tableDataForTuDiHandledResult.tableRowSpanInfoList;
    let handledTableColSpanInfoListOfLandUseType = tableDataForTuDiHandledResult.tableColSpanInfoList.filter(ele => ele.colSpan > 2);
    const landUseTypeDistribution = [
        {
            landType: "林地",
            children: [
                "乔木林地",
                "竹林地",
                "灌木林地",
                "其他林地"
            ],
        },
        {
            landType: "草地",
            children: [
                "天然牧草地",
                "人工牧草地",
                "其他草地",
            ],
        },
        {
            landType: "湿地",
            children: [
                "森林沼泽",
                "灌丛沼泽",
                "沼泽草地",
                "其他沼泽地",
                "沿海滩涂",
                "内陆滩涂",
                "红树林地",
            ],
        },
        {
            landType: "园地",
            children: [
                "果园",
                "茶园",
                "橡胶园地",
                "油料园地",
                "其他园地",
            ],
        },
        {
            landType: "陆地水域",
            children: [
                "河流水面",
                "湖泊水面",
                "水库水面",
                "坑塘水面",
                "沟渠",
                "冰川及常年积雪",
            ],
        },
        {
            landType: "耕地",
            children: [],
        },
        {
            landType: "居住用地",
            children: [],
        },
        {
            landType: "公共管理与公共服务用地",
            children: [],
        },
        {
            landType: "商业服务业用地",
            children: [],
        },
        {
            landType: "工矿用地",
            children: [],
        },
        {
            landType: "仓储用地",
            children: [],
        },
        {
            landType: "交通运输用地",
            children: [],
        },
        {
            landType: "公用设施用地",
            children: [],
        },
        {
            landType: "绿地与开敞空间用地",
            children: [],
        },
        {
            landType: "特殊用地",
            children: [],
        },
        {
            landType: "留白用地",
            children: [],
        },
        {
            landType: "其他土地",
            children: [],
        },
        {
            landType: "渔业用海",
            children: [],
        },
        {
            landType: "工矿通信用海",
            children: [],
        },
        {
            landType: "交通运输用海",
            children: [],
        },
        {
            landType: "游憩用海",
            children: [],
        },
        {
            landType: "特殊用海",
            children: [],
        },
        {
            landType: "其他海域",
            children: [],
        },
    ]
    let landUseSubTypeParagraphPlainTextList: string[] = [];
    landUseTypeDistribution.forEach(((landUseType, landUseTypeIndex) => {
        const landUseTypeFindIndex = findCellValuColIndex(handledTableDataOfLandUseType[0], landUseType.landType);
        if (landUseTypeFindIndex > -1) {
            let landUseSubTypeFindIndexList: { landUseSubType: string; findIndex: number }[] = [];
            landUseType.children.forEach((lanUseSubTypeName => {
                const tempLandUseSubTypeFindIndex = findCellValuColIndex(handledTableDataOfLandUseType[1], lanUseSubTypeName);
                if (tempLandUseSubTypeFindIndex > -1) {
                    landUseSubTypeFindIndexList.push({
                        landUseSubType: lanUseSubTypeName,
                        findIndex: tempLandUseSubTypeFindIndex
                    })
                }
            }))
            const landUseTypeArea = getCellValueTotalByColGroup(handledTableDataOfLandUseType, landUseTypeFindIndex, 2, handledTableDataOfLandUseType.length - 1);
            if (landUseTypeIndex == 0) {
                tempParagraph2_1 += '其中'
            }
            tempParagraph2_1 += `${landUseType.landType}${landUseTypeArea}公顷，占总面积的${getPercentRate(landUseTypeArea, totalLandUseArea)}%；`;
            if (landUseSubTypeFindIndexList.length == 1) {
                handledTableDataOfLandUseType = removeAndAdjustColumn(handledTableDataOfLandUseType, landUseTypeFindIndex, handledTableRowSpanInfoListOfLandUseType, handledTableColSpanInfoListOfLandUseType);
                const deletedColIndex = landUseSubTypeFindIndexList[0].findIndex - 1;
                handledTableDataOfLandUseType[0][deletedColIndex] = landUseType.landType;
                handledTableDataOfLandUseType[1][deletedColIndex] = "";
                handledTableRowSpanInfoListOfLandUseType.push({
                    rowIndex: 0,
                    colIndex: deletedColIndex,
                    rowSpan: 2,
                })
            }
        }
    }))
    landUseTypeDistribution.forEach((landUseType => {
        const landUseTypeFindIndex = findCellValuColIndex(handledTableDataOfLandUseType[0], landUseType.landType);
        if (landUseTypeFindIndex > -1) {
            const landUseTypeArea = getCellValueTotalByColGroup(handledTableDataOfLandUseType, landUseTypeFindIndex, 2, handledTableDataOfLandUseType.length - 1);
            let landUseSubTypeFindIndexList: { landUseSubType: string; findIndex: number }[] = [];
            landUseType.children.forEach((lanUseSubTypeName => {
                const tempLandUseSubTypeFindIndex = findCellValuColIndex(handledTableDataOfLandUseType[1], lanUseSubTypeName);
                if (tempLandUseSubTypeFindIndex > -1) {
                    landUseSubTypeFindIndexList.push({
                        landUseSubType: lanUseSubTypeName,
                        findIndex: tempLandUseSubTypeFindIndex
                    })
                }
            }))
            if (landUseSubTypeFindIndexList.length > 2) {
                let tempParagraphSlice1 = `在${landUseType.landType}中，`;
                landUseSubTypeFindIndexList.forEach(landUseSubTypeInfo => {
                    let tempLandUseSubTypeArea = getCellValueTotalByColGroup(handledTableDataOfLandUseType, landUseSubTypeInfo.findIndex, 2, handledTableDataOfLandUseType.length - 1);
                    if (Number(tempLandUseSubTypeArea) > 0) {
                        tempParagraphSlice1 += `${landUseSubTypeInfo.landUseSubType}面积${tempLandUseSubTypeArea}公顷，占${landUseType.landType}面积的${getPercentRate(tempLandUseSubTypeArea, landUseTypeArea)}%；`
                    }
                })
                tempParagraphSlice1 = replaceLastCharWithPeriod(tempParagraphSlice1);
                landUseSubTypeParagraphPlainTextList.push(tempParagraphSlice1);
            }
        }
    }))
    tempParagraph2_1 = replaceLastCharWithPeriod(tempParagraph2_1);
    tempWordParahraphList2.push({
        type: 'Text',
        text: tempParagraph2_1,
        paragraphType: 'normalParagraph'
    })
    landUseSubTypeParagraphPlainTextList.forEach(str => {
        tempWordParahraphList2.push({
            type: 'Text',
            text: str,
            paragraphType: 'normalParagraph'
        })
    })

    tempWordParahraphList2.push({
        type: 'Text',
        isSubTable: true,
        text: `附表  ${protectlandName}土地利用现状表`,
        paragraphType: 'smallTableName'
    })
    tempWordParahraphList2.push({
        type: 'Table',
        text: "表格",
        isSubTable: true,
        tableName: `附表  ${protectlandName}土地利用现状表`,
        tableData: handledTableDataOfLandUseType,
        tableHeaderRowNumber: 2,
        rowSpanInfoList: handledTableRowSpanInfoListOfLandUseType,
        colSpanInfoList: handledTableColSpanInfoListOfLandUseType
    });
    return processWordParagraphBlockList(tempWordParahraphList2);
}

export default landUseTypeAnalysis;